<html>
<head>
    <title>DatabaseHandler.java</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
        .ln { color: rgb(0,0,0); font-weight: normal; font-style: normal; }
        .s0 { color: rgb(0,0,128); font-weight: bold; }
        .s1 { }
        .s2 { color: rgb(128,128,128); font-style: italic; }
        .s3 { color: rgb(0,128,0); font-weight: bold; }
        .s4 { color: rgb(0,0,255); }
    </style>
</head>
<BODY BGCOLOR="#ffffff">
<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#C0C0C0">
    <TR>
        <TD>
            <CENTER>
                <FONT FACE="Arial, Helvetica" COLOR="#000000">
                    DatabaseHandler.java</FONT>
            </center>
        </TD>
    </TR>
</TABLE>
<pre>

<a name="l1"><span class="ln">1    </span></a><span class="s0">package </span><span class="s1">com.ibr.ticketmanagement.app.util; 
<a name="l2"><span class="ln">2    </span></a> 
<a name="l3"><span class="ln">3    </span></a></span><span class="s0">import </span><span
        class="s1">android.content.Context;
<a name="l4"><span class="ln">4    </span></a></span><span class="s0">import </span><span
        class="s1">android.database.Cursor;
<a name="l5"><span class="ln">5    </span></a></span><span class="s0">import </span><span
        class="s1">android.database.sqlite.SQLiteDatabase;
<a name="l6"><span class="ln">6    </span></a></span><span class="s0">import </span><span
        class="s1">android.database.sqlite.SQLiteOpenHelper;
<a name="l7"><span class="ln">7    </span></a> 
<a name="l8"><span class="ln">8    </span></a></span><span class="s0">import <a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">com.ibr.ticketmanagement.app.data.ActionPlan</a></span><span
        class="s1">;
<a name="l9"><span class="ln">9    </span></a></span><span class="s0">import <a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">com.ibr.ticketmanagement.app.data.FEReport</a></span><span
        class="s1">;
<a name="l10"><span class="ln">10   </span></a> 
<a name="l11"><span class="ln">11   </span></a></span><span class="s0">import </span><span
        class="s1">java.util.ArrayList;
<a name="l12"><span class="ln">12   </span></a></span><span class="s0">import </span><span
        class="s1">java.util.List;
<a name="l13"><span class="ln">13   </span></a> 
<a name="l14"><span class="ln">14   </span></a></span><span class="s0">public class </span><span
        class="s1">DatabaseHandler </span><span class="s0">extends </span><span class="s1">SQLiteOpenHelper {
<a name="l15"><span class="ln">15   </span></a> 
<a name="l16"><span class="ln">16   </span></a>    </span><span class="s2">// Action Plan Table Columns names</span><span
        class="s1">
<a name="l17"><span class="ln">17   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_AP_ID = </span><span
        class="s3">&quot;id&quot;</span><span class="s1">;
<a name="l18"><span class="ln">18   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_AP_TICKET_ID = </span><span
        class="s3">&quot;ticket_id&quot;</span><span class="s1">;
<a name="l19"><span class="ln">19   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_AP_NAME = </span><span
        class="s3">&quot;name&quot;</span><span class="s1">;
<a name="l20"><span class="ln">20   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_AP_ACTION_PLAN = </span><span
        class="s3">&quot;action_plan&quot;</span><span class="s1">;
<a name="l21"><span class="ln">21   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_AP_WWSTART = </span><span
        class="s3">&quot;ww_start&quot;</span><span class="s1">;
<a name="l22"><span class="ln">22   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_AP_SITE_CONTACT = </span><span
        class="s3">&quot;site_contact&quot;</span><span class="s1">;
<a name="l23"><span class="ln">23   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_AP_SITE_ACCESS = </span><span
        class="s3">&quot;site_access&quot;</span><span class="s1">;
<a name="l24"><span class="ln">24   </span></a>    </span><span class="s2">// FE Report Table Columns names</span><span
        class="s1">
<a name="l25"><span class="ln">25   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_FE_ID = </span><span
        class="s3">&quot;id&quot;</span><span class="s1">;
<a name="l26"><span class="ln">26   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_FE_TICKET_ID = </span><span
        class="s3">&quot;ticket_id&quot;</span><span class="s1">;
<a name="l27"><span class="ln">27   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_FE_ACTION_PLAN = </span><span
        class="s3">&quot;action_plan_id&quot;</span><span class="s1">;
<a name="l28"><span class="ln">28   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_FE_FIELD_ENGINEER_ID = </span><span class="s3">&quot;field_engineer_id&quot;</span><span
        class="s1">;
<a name="l29"><span class="ln">29   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_FE_WORK_WINDOW = </span><span
        class="s3">&quot;work_window&quot;</span><span class="s1">;
<a name="l30"><span class="ln">30   </span></a>    </span><span
        class="s0">public static final </span><span
        class="s1">String KEY_FE_TIME_START = </span><span
        class="s3">&quot;time_start&quot;</span><span class="s1">;
<a name="l31"><span class="ln">31   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_FE_TIME_FINISHED = </span><span
        class="s3">&quot;time_finished&quot;</span><span class="s1">;
<a name="l32"><span class="ln">32   </span></a>    </span><span
        class="s0">public static final </span><span class="s1">String KEY_FE_SENT = </span><span
        class="s3">&quot;sent&quot;</span><span class="s1">;
<a name="l33"><span class="ln">33   </span></a>    </span><span
        class="s2">// All Static variables</span><span class="s1">
<a name="l34"><span class="ln">34   </span></a>    </span><span
        class="s2">// Database Version</span><span class="s1">
<a name="l35"><span class="ln">35   </span></a>    </span><span
        class="s0">private static final int </span><span class="s1">DATABASE_VERSION = </span><span
        class="s4">1</span><span class="s1">;
<a name="l36"><span class="ln">36   </span></a>    </span><span
        class="s2">// Database Name</span><span class="s1">
<a name="l37"><span class="ln">37   </span></a>    </span><span
        class="s0">private static final </span><span class="s1">String DATABASE_NAME = </span><span
        class="s3">&quot;ibrReport&quot;</span><span class="s1">;
<a name="l38"><span class="ln">38   </span></a>    </span><span
        class="s2">// Contacts table name</span><span class="s1">
<a name="l39"><span class="ln">39   </span></a>    </span><span
        class="s0">private static final </span><span
        class="s1">String TABLE_ACTION_PLAN = </span><span class="s3">&quot;action_plan&quot;</span><span
        class="s1">;
<a name="l40"><span class="ln">40   </span></a>    </span><span
        class="s0">private static final </span><span
        class="s1">String TABLE_FE_REPORT = </span><span
        class="s3">&quot;fe_report&quot;</span><span class="s1">;
<a name="l41"><span class="ln">41   </span></a> 
<a name="l42"><span class="ln">42   </span></a> 
<a name="l43"><span class="ln">43   </span></a>    </span><span class="s0">public </span><span
        class="s1">DatabaseHandler(Context context) {
<a name="l44"><span class="ln">44   </span></a>        </span><span class="s0">super</span><span
        class="s1">(context, DATABASE_NAME, </span><span class="s0">null</span><span class="s1">, DATABASE_VERSION);
<a name="l45"><span class="ln">45   </span></a>    } 
<a name="l46"><span class="ln">46   </span></a> 
<a name="l47"><span class="ln">47   </span></a>    </span><span class="s2">// Creating Tables</span><span
        class="s1">
<a name="l48"><span class="ln">48   </span></a>    @Override 
<a name="l49"><span class="ln">49   </span></a>    </span><span class="s0">public void </span><span
        class="s1">onCreate(SQLiteDatabase db) {
<a name="l50"><span
        class="ln">50   </span></a>        String CREATE_ACTION_PLAN_TABLE = </span><span
        class="s3">&quot;CREATE TABLE &quot; </span><span
        class="s1">+ TABLE_ACTION_PLAN + </span><span class="s3">&quot;(&quot;</span><span
        class="s1">
<a name="l51"><span class="ln">51   </span></a>                + KEY_AP_ID + </span><span
        class="s3">&quot; INTEGER PRIMARY KEY,&quot;</span><span class="s1">
<a name="l52"><span class="ln">52   </span></a>                + KEY_AP_TICKET_ID + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l53"><span class="ln">53   </span></a>                + KEY_AP_NAME + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l54"><span class="ln">54   </span></a>                + KEY_AP_ACTION_PLAN + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l55"><span class="ln">55   </span></a>                + KEY_AP_WWSTART + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l56"><span class="ln">56   </span></a>                + KEY_AP_SITE_CONTACT + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l57"><span class="ln">57   </span></a>                + KEY_AP_SITE_ACCESS + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l58"><span class="ln">58   </span></a>                + KEY_AP_ACTION_PLAN + </span><span
        class="s3">&quot; TEXT&quot; </span><span class="s1">+ </span><span
        class="s3">&quot;)&quot;</span><span class="s1">;
<a name="l59"><span class="ln">59   </span></a>        db.execSQL(CREATE_ACTION_PLAN_TABLE); 
<a name="l60"><span class="ln">60   </span></a>        String CREATE_FE_REPORT_TABLE = </span><span
        class="s3">&quot;CREATE TABLE &quot; </span><span
        class="s1">+ TABLE_FE_REPORT + </span><span class="s3">&quot;(&quot;</span><span class="s1">
<a name="l61"><span class="ln">61   </span></a>                + KEY_FE_ID + </span><span
        class="s3">&quot; INTEGER PRIMARY KEY,&quot; </span><span
        class="s1">+ KEY_FE_TICKET_ID + </span><span class="s3">&quot; TEXT,&quot;</span><span
        class="s1">
<a name="l62"><span class="ln">62   </span></a>                + KEY_FE_ACTION_PLAN + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l63"><span
        class="ln">63   </span></a>                + KEY_FE_FIELD_ENGINEER_ID + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l64"><span class="ln">64   </span></a>                + KEY_FE_WORK_WINDOW + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l65"><span class="ln">65   </span></a>                + KEY_FE_TIME_START + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l66"><span class="ln">66   </span></a>                + KEY_FE_TIME_FINISHED + </span><span
        class="s3">&quot; TEXT,&quot;</span><span class="s1">
<a name="l67"><span class="ln">67   </span></a>                + KEY_FE_SENT + </span><span
        class="s3">&quot; TEXT&quot; </span><span class="s1">+ </span><span
        class="s3">&quot;)&quot;</span><span class="s1">;
<a name="l68"><span class="ln">68   </span></a>        db.execSQL(CREATE_FE_REPORT_TABLE); 
<a name="l69"><span class="ln">69   </span></a>    } 
<a name="l70"><span class="ln">70   </span></a> 
<a name="l71"><span class="ln">71   </span></a>    </span><span
        class="s2">// Upgrading database</span><span class="s1">
<a name="l72"><span class="ln">72   </span></a>    @Override 
<a name="l73"><span class="ln">73   </span></a>    </span><span class="s0">public void </span><span
        class="s1">onUpgrade(SQLiteDatabase db, </span><span class="s0">int </span><span class="s1">oldVersion, </span><span
        class="s0">int </span><span class="s1">newVersion) {
<a name="l74"><span class="ln">74   </span></a>        </span><span class="s2">// Drop older table if existed</span><span
        class="s1">
<a name="l75"><span class="ln">75   </span></a>        db.execSQL(</span><span class="s3">&quot;DROP TABLE IF EXISTS &quot; </span><span
        class="s1">+ TABLE_ACTION_PLAN);
<a name="l76"><span class="ln">76   </span></a>        db.execSQL(</span><span class="s3">&quot;DROP TABLE IF EXISTS &quot; </span><span
        class="s1">+ TABLE_FE_REPORT);
<a name="l77"><span class="ln">77   </span></a> 
<a name="l78"><span class="ln">78   </span></a>        </span><span class="s2">// Create tables again</span><span
        class="s1">
<a name="l79"><span class="ln">79   </span></a>        onCreate(db); 
<a name="l80"><span class="ln">80   </span></a>    } 
<a name="l81"><span class="ln">81   </span></a> 
<a name="l82"><span class="ln">82   </span></a>    </span><span class="s2">/** 
<a name="l83"><span class="ln">83   </span></a>     * All CRUD(Create, Read, Update, Delete) Operations 
<a name="l84"><span class="ln">84   </span></a>     */</span><span class="s1"> 
<a name="l85"><span class="ln">85   </span></a> 
<a name="l86"><span class="ln">86   </span></a>    </span><span
        class="s2">// Adding new FEReport</span><span class="s1">
<a name="l87"><span class="ln">87   </span></a>    </span><span class="s0">void </span><span
        class="s1">addFEReport(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a> feReport) {
<a name="l88"><span class="ln">88   </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l89"><span class="ln">89   </span></a>        </span><span
        class="s2">// Inserting Row</span><span class="s1">
<a name="l90"><span class="ln">90   </span></a>        db.insert(TABLE_FE_REPORT, </span><span
        class="s0">null</span><span class="s1">, feReport.getContentValues());
<a name="l91"><span class="ln">91   </span></a>        db.close(); </span><span class="s2">// Closing database connection</span><span
        class="s1">
<a name="l92"><span class="ln">92   </span></a>    } 
<a name="l93"><span class="ln">93   </span></a> 
<a name="l94"><span class="ln">94   </span></a>    </span><span
        class="s2">// Adding new ActionPlan</span><span class="s1">
<a name="l95"><span class="ln">95   </span></a>    </span><span class="s0">void </span><span
        class="s1">addActionPlan(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a> actionPlan) {
<a name="l96"><span class="ln">96   </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l97"><span class="ln">97   </span></a>        </span><span
        class="s2">// Inserting Row</span><span class="s1">
<a name="l98"><span class="ln">98   </span></a>        db.insert(TABLE_ACTION_PLAN, </span><span
        class="s0">null</span><span class="s1">, actionPlan.getContentValues());
<a name="l99"><span class="ln">99   </span></a>        db.close(); </span><span class="s2">// Closing database connection</span><span
        class="s1">
<a name="l100"><span class="ln">100  </span></a>    } 
<a name="l101"><span class="ln">101  </span></a> 
<a name="l102"><span class="ln">102  </span></a>    </span><span class="s2">// Getting single FEReport</span><span
        class="s1">
<a name="l103"><span class="ln">103  </span></a>    <a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a> getFEReport(</span><span
        class="s0">int </span><span class="s1">id) {
<a name="l104"><span class="ln">104  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getReadableDatabase();
<a name="l105"><span class="ln">105  </span></a> 
<a name="l106"><span
        class="ln">106  </span></a>        Cursor cursor = db.query(TABLE_FE_REPORT, </span><span
        class="s0">new </span><span class="s1">String[]{KEY_FE_ID,
<a name="l107"><span class="ln">107  </span></a>                        KEY_FE_TICKET_ID, KEY_FE_ACTION_PLAN, 
<a name="l108"><span class="ln">108  </span></a>                        KEY_FE_FIELD_ENGINEER_ID, KEY_FE_WORK_WINDOW, 
<a name="l109"><span class="ln">109  </span></a>                        KEY_FE_TIME_START, KEY_FE_TIME_FINISHED, KEY_FE_SENT}, KEY_FE_ID + </span><span
        class="s3">&quot;=?&quot;</span><span class="s1">,
<a name="l110"><span class="ln">110  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(id)}, </span><span
        class="s0">null</span><span class="s1">, </span><span class="s0">null</span><span
        class="s1">, </span><span class="s0">null</span><span class="s1">, </span><span class="s0">null</span><span
        class="s1">
<a name="l111"><span class="ln">111  </span></a>        ); 
<a name="l112"><span class="ln">112  </span></a>        </span><span class="s0">if </span><span
        class="s1">(cursor != </span><span class="s0">null</span><span class="s1">)
<a name="l113"><span class="ln">113  </span></a>            cursor.moveToFirst(); 
<a name="l114"><span class="ln">114  </span></a> 
<a name="l115"><span class="ln">115  </span></a>        </span><span class="s0">return </span><span
        class="s1">formFEReport(cursor);
<a name="l116"><span class="ln">116  </span></a>    } 
<a name="l117"><span class="ln">117  </span></a> 
<a name="l118"><span class="ln">118  </span></a>    </span><span class="s2">// Getting single ActionPlan</span><span
        class="s1">
<a name="l119"><span class="ln">119  </span></a>    <a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a> getActionPlan(</span><span
        class="s0">int </span><span class="s1">id) {
<a name="l120"><span class="ln">120  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getReadableDatabase();
<a name="l121"><span class="ln">121  </span></a> 
<a name="l122"><span class="ln">122  </span></a>        Cursor cursor = db.query(TABLE_ACTION_PLAN, </span><span
        class="s0">new </span><span class="s1">String[]{KEY_AP_ID,
<a name="l123"><span class="ln">123  </span></a>                        KEY_AP_TICKET_ID, KEY_AP_NAME, 
<a name="l124"><span class="ln">124  </span></a>                        KEY_AP_WWSTART, KEY_AP_ACTION_PLAN, 
<a name="l125"><span class="ln">125  </span></a>                        KEY_AP_SITE_CONTACT, KEY_AP_SITE_ACCESS}, KEY_AP_ID + </span><span
        class="s3">&quot;=?&quot;</span><span class="s1">,
<a name="l126"><span class="ln">126  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(id)}, </span><span
        class="s0">null</span><span class="s1">, </span><span class="s0">null</span><span
        class="s1">, </span><span class="s0">null</span><span class="s1">, </span><span class="s0">null</span><span
        class="s1">
<a name="l127"><span class="ln">127  </span></a>        ); 
<a name="l128"><span class="ln">128  </span></a>        </span><span class="s0">if </span><span
        class="s1">(cursor != </span><span class="s0">null</span><span class="s1">)
<a name="l129"><span class="ln">129  </span></a>            cursor.moveToFirst(); 
<a name="l130"><span class="ln">130  </span></a> 
<a name="l131"><span class="ln">131  </span></a>        </span><span class="s0">return </span><span
        class="s1">formActionPlan(cursor);
<a name="l132"><span class="ln">132  </span></a>    } 
<a name="l133"><span class="ln">133  </span></a> 
<a name="l134"><span class="ln">134  </span></a>    </span><span class="s0">private <a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a> </span><span
        class="s1">formFEReport(Cursor cursor) {
<a name="l135"><span class="ln">135  </span></a>        </span><span class="s0">return new <a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a></span><span
        class="s1">(Integer.parseInt(cursor.getString(</span><span class="s4">0</span><span
        class="s1">)),
<a name="l136"><span
        class="ln">136  </span></a>                Integer.parseInt(cursor.getString(</span><span
        class="s4">1</span><span class="s1">)),
<a name="l137"><span
        class="ln">137  </span></a>                Integer.parseInt(cursor.getString(</span><span
        class="s4">2</span><span class="s1">)),
<a name="l138"><span
        class="ln">138  </span></a>                Integer.parseInt(cursor.getString(</span><span
        class="s4">3</span><span class="s1">)),
<a name="l139"><span class="ln">139  </span></a>                cursor.getString(</span><span
        class="s4">4</span><span class="s1">),
<a name="l140"><span class="ln">140  </span></a>                cursor.getString(</span><span
        class="s4">5</span><span class="s1">),
<a name="l141"><span class="ln">141  </span></a>                cursor.getString(</span><span
        class="s4">6</span><span class="s1">),
<a name="l142"><span
        class="ln">142  </span></a>                Boolean.valueOf(cursor.getString(</span><span
        class="s4">7</span><span class="s1">)));
<a name="l143"><span class="ln">143  </span></a>    } 
<a name="l144"><span class="ln">144  </span></a> 
<a name="l145"><span class="ln">145  </span></a>    </span><span class="s0">private <a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a> </span><span
        class="s1">formActionPlan(Cursor cursor) {
<a name="l146"><span class="ln">146  </span></a>        </span><span class="s0">return new <a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a></span><span
        class="s1">(Integer.parseInt(cursor.getString(</span><span class="s4">0</span><span
        class="s1">)),
<a name="l147"><span
        class="ln">147  </span></a>                Integer.parseInt(cursor.getString(</span><span
        class="s4">1</span><span class="s1">)),
<a name="l148"><span class="ln">148  </span></a>                cursor.getString(</span><span
        class="s4">2</span><span class="s1">),
<a name="l149"><span class="ln">149  </span></a>                cursor.getString(</span><span
        class="s4">3</span><span class="s1">),
<a name="l150"><span class="ln">150  </span></a>                cursor.getString(</span><span
        class="s4">4</span><span class="s1">),
<a name="l151"><span class="ln">151  </span></a>                cursor.getString(</span><span
        class="s4">4</span><span class="s1">),
<a name="l152"><span class="ln">152  </span></a>                cursor.getString(</span><span
        class="s4">4</span><span class="s1">));
<a name="l153"><span class="ln">153  </span></a>    } 
<a name="l154"><span class="ln">154  </span></a> 
<a name="l155"><span class="ln">155  </span></a>    </span><span
        class="s2">// Getting All FEReports</span><span class="s1">
<a name="l156"><span class="ln">156  </span></a>    </span><span class="s0">public </span><span
        class="s1">List&lt;FEReport&gt; getAllFEReports() {
<a name="l157"><span
        class="ln">157  </span></a>        List&lt;FEReport&gt; feReportList = </span><span
        class="s0">new </span><span class="s1">ArrayList&lt;FEReport&gt;();
<a name="l158"><span class="ln">158  </span></a>        </span><span
        class="s2">// Select All Query</span><span class="s1">
<a name="l159"><span class="ln">159  </span></a>        String selectQuery = </span><span
        class="s3">&quot;SELECT  * FROM &quot; </span><span class="s1">+ TABLE_FE_REPORT;
<a name="l160"><span class="ln">160  </span></a> 
<a name="l161"><span class="ln">161  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l162"><span
        class="ln">162  </span></a>        Cursor cursor = db.rawQuery(selectQuery, </span><span
        class="s0">null</span><span class="s1">);
<a name="l163"><span class="ln">163  </span></a> 
<a name="l164"><span class="ln">164  </span></a>        </span><span class="s2">// looping through all rows and adding to list</span><span
        class="s1">
<a name="l165"><span class="ln">165  </span></a>        </span><span class="s0">if </span><span
        class="s1">(cursor.moveToFirst()) {
<a name="l166"><span class="ln">166  </span></a>            </span><span class="s0">do </span><span
        class="s1">{
<a name="l167"><span class="ln">167  </span></a>                feReportList.add(formFEReport(cursor)); 
<a name="l168"><span class="ln">168  </span></a>            } </span><span
        class="s0">while </span><span class="s1">(cursor.moveToNext());
<a name="l169"><span class="ln">169  </span></a>        } 
<a name="l170"><span class="ln">170  </span></a> 
<a name="l171"><span class="ln">171  </span></a>        </span><span class="s0">return </span><span
        class="s1">feReportList;
<a name="l172"><span class="ln">172  </span></a>    } 
<a name="l173"><span class="ln">173  </span></a> 
<a name="l174"><span class="ln">174  </span></a>    </span><span class="s2">// Getting All ActionPlan</span><span
        class="s1">
<a name="l175"><span class="ln">175  </span></a>    </span><span class="s0">public </span><span
        class="s1">List&lt;ActionPlan&gt; getAllActionPlans() {
<a name="l176"><span
        class="ln">176  </span></a>        List&lt;ActionPlan&gt; actionPlanList = </span><span
        class="s0">new </span><span class="s1">ArrayList&lt;ActionPlan&gt;();
<a name="l177"><span class="ln">177  </span></a>        </span><span
        class="s2">// Select All Query</span><span class="s1">
<a name="l178"><span class="ln">178  </span></a>        String selectQuery = </span><span
        class="s3">&quot;SELECT  * FROM &quot; </span><span class="s1">+ TABLE_ACTION_PLAN;
<a name="l179"><span class="ln">179  </span></a> 
<a name="l180"><span class="ln">180  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l181"><span
        class="ln">181  </span></a>        Cursor cursor = db.rawQuery(selectQuery, </span><span
        class="s0">null</span><span class="s1">);
<a name="l182"><span class="ln">182  </span></a> 
<a name="l183"><span class="ln">183  </span></a>        </span><span class="s2">// looping through all rows and adding to list</span><span
        class="s1">
<a name="l184"><span class="ln">184  </span></a>        </span><span class="s0">if </span><span
        class="s1">(cursor.moveToFirst()) {
<a name="l185"><span class="ln">185  </span></a>            </span><span class="s0">do </span><span
        class="s1">{
<a name="l186"><span class="ln">186  </span></a>                actionPlanList.add(formActionPlan(cursor)); 
<a name="l187"><span class="ln">187  </span></a>            } </span><span
        class="s0">while </span><span class="s1">(cursor.moveToNext());
<a name="l188"><span class="ln">188  </span></a>        } 
<a name="l189"><span class="ln">189  </span></a> 
<a name="l190"><span class="ln">190  </span></a>        </span><span class="s0">return </span><span
        class="s1">actionPlanList;
<a name="l191"><span class="ln">191  </span></a>    } 
<a name="l192"><span class="ln">192  </span></a> 
<a name="l193"><span class="ln">193  </span></a>    </span><span class="s2">// Updating single FEReport</span><span
        class="s1">
<a name="l194"><span class="ln">194  </span></a>    </span><span class="s0">public int </span><span
        class="s1">updateFEReport(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a> feReport) {
<a name="l195"><span class="ln">195  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l196"><span class="ln">196  </span></a> 
<a name="l197"><span class="ln">197  </span></a>        </span><span
        class="s2">// updating row</span><span class="s1">
<a name="l198"><span class="ln">198  </span></a>        </span><span class="s0">return </span><span
        class="s1">db.update(TABLE_FE_REPORT, feReport.getContentValues(), KEY_FE_ID + </span><span
        class="s3">&quot; = ?&quot;</span><span class="s1">,
<a name="l199"><span class="ln">199  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(feReport.get_id())});
<a name="l200"><span class="ln">200  </span></a>    } 
<a name="l201"><span class="ln">201  </span></a> 
<a name="l202"><span class="ln">202  </span></a>    </span><span class="s2">// Updating single ActionPlan</span><span
        class="s1">
<a name="l203"><span class="ln">203  </span></a>    </span><span class="s0">public int </span><span
        class="s1">updateActionPlan(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a> actionPlan) {
<a name="l204"><span class="ln">204  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l205"><span class="ln">205  </span></a> 
<a name="l206"><span class="ln">206  </span></a>        </span><span
        class="s2">// updating row</span><span class="s1">
<a name="l207"><span class="ln">207  </span></a>        </span><span class="s0">return </span><span
        class="s1">db.update(TABLE_ACTION_PLAN, actionPlan.getContentValues(), KEY_AP_ID + </span><span
        class="s3">&quot; = ?&quot;</span><span class="s1">,
<a name="l208"><span class="ln">208  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(actionPlan.get_id())});
<a name="l209"><span class="ln">209  </span></a>    } 
<a name="l210"><span class="ln">210  </span></a> 
<a name="l211"><span class="ln">211  </span></a>    </span><span class="s2">// Deleting single FEReport</span><span
        class="s1">
<a name="l212"><span class="ln">212  </span></a>    </span><span class="s0">public void </span><span
        class="s1">deleteFEReport(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/FEReport.java.html">FEReport</a> feReport) {
<a name="l213"><span class="ln">213  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l214"><span
        class="ln">214  </span></a>        db.delete(TABLE_FE_REPORT, KEY_FE_ID + </span><span
        class="s3">&quot; = ?&quot;</span><span class="s1">,
<a name="l215"><span class="ln">215  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(feReport.get_id())});
<a name="l216"><span class="ln">216  </span></a>        db.close(); 
<a name="l217"><span class="ln">217  </span></a>    } 
<a name="l218"><span class="ln">218  </span></a> 
<a name="l219"><span class="ln">219  </span></a>    </span><span class="s2">// Deleting single ActionPlan</span><span
        class="s1">
<a name="l220"><span class="ln">220  </span></a>    </span><span class="s0">public void </span><span
        class="s1">deleteActionPlan(<a
        href="../../../../../com/ibr/ticketmanagement/app/data/ActionPlan.java.html">ActionPlan</a> actionPlan) {
<a name="l221"><span class="ln">221  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getWritableDatabase();
<a name="l222"><span
        class="ln">222  </span></a>        db.delete(TABLE_ACTION_PLAN, KEY_AP_ID + </span><span
        class="s3">&quot; = ?&quot;</span><span class="s1">,
<a name="l223"><span class="ln">223  </span></a>                </span><span
        class="s0">new </span><span class="s1">String[]{String.valueOf(actionPlan.get_id())});
<a name="l224"><span class="ln">224  </span></a>        db.close(); 
<a name="l225"><span class="ln">225  </span></a>    } 
<a name="l226"><span class="ln">226  </span></a> 
<a name="l227"><span class="ln">227  </span></a>    </span><span class="s2">// Getting ActionPlan Count</span><span
        class="s1">
<a name="l228"><span class="ln">228  </span></a>    </span><span class="s0">public int </span><span
        class="s1">getActionPlanCount() {
<a name="l229"><span class="ln">229  </span></a>        String countQuery = </span><span class="s3">&quot;SELECT  * FROM &quot; </span><span
        class="s1">+ TABLE_ACTION_PLAN;
<a name="l230"><span class="ln">230  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getReadableDatabase();
<a name="l231"><span
        class="ln">231  </span></a>        Cursor cursor = db.rawQuery(countQuery, </span><span
        class="s0">null</span><span class="s1">);
<a name="l232"><span class="ln">232  </span></a>        cursor.close(); 
<a name="l233"><span class="ln">233  </span></a> 
<a name="l234"><span class="ln">234  </span></a>        </span><span
        class="s2">// return count</span><span class="s1">
<a name="l235"><span class="ln">235  </span></a>        </span><span class="s0">return </span><span
        class="s1">cursor.getCount();
<a name="l236"><span class="ln">236  </span></a>    } 
<a name="l237"><span class="ln">237  </span></a> 
<a name="l238"><span class="ln">238  </span></a>    </span><span class="s2">// Getting FEReport Count</span><span
        class="s1">
<a name="l239"><span class="ln">239  </span></a>    </span><span class="s0">public int </span><span
        class="s1">getFEReportCount() {
<a name="l240"><span class="ln">240  </span></a>        String countQuery = </span><span class="s3">&quot;SELECT  * FROM &quot; </span><span
        class="s1">+ TABLE_FE_REPORT;
<a name="l241"><span class="ln">241  </span></a>        SQLiteDatabase db = </span><span class="s0">this</span><span
        class="s1">.getReadableDatabase();
<a name="l242"><span
        class="ln">242  </span></a>        Cursor cursor = db.rawQuery(countQuery, </span><span
        class="s0">null</span><span class="s1">);
<a name="l243"><span class="ln">243  </span></a>        cursor.close(); 
<a name="l244"><span class="ln">244  </span></a> 
<a name="l245"><span class="ln">245  </span></a>        </span><span
        class="s2">// return count</span><span class="s1">
<a name="l246"><span class="ln">246  </span></a>        </span><span class="s0">return </span><span
        class="s1">cursor.getCount();
<a name="l247"><span class="ln">247  </span></a>    } 
<a name="l248"><span class="ln">248  </span></a> 
<a name="l249"><span class="ln">249  </span></a>} 
<a name="l250"><span class="ln">250  </span></a></span></pre>
</body>
</html>